<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>订单信息管理</title>
	<meta name="decorator" content="default"/>
	<link rel="stylesheet" href="css/layui.css">
	<script src="/static/layui/layui.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function tianchu(){
            layui.use(['layer','jquery'], function () {
                <%--layer.open({--%>
                    <%--type : 2,--%>
                    <%--title : '选择物品',--%>
                    <%--area: ['700px', '500px'],--%>
                    <%--content : '${ctx}/bishe/bisheOrder/relation'--%>
                <%--});--%>
                index = layer.open({
                    type: 2//0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                    , title: '住址'
                    , area: ['700px', '500px']
                    , offset: '40px'
                    , content: '${ctx}/bishe/bisheOrder/relation'
                    , btn: ["确定"]
                    ,yes: function(index, layero){
                        var res = window["layui-layer-iframe" + index].xuanze();
                        // //打印返回的值，看是否有我们想返回的值。

						var str="";
                        for (var key in res) {
                            str+="<tr>" +
                                "<td>"+res[key]+"</td>" +
                                "<td><input type='number' required name='table"+key+"' placeholder=\"请输入数量\" />" +
								"</td>" +
                                "</tr>";

                        }
                        $("#table").html(str)

                        layer.close(index); //如果设定了yes回调，需进行手工关闭
                    }
                });

            })


		}


	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/bishe/bisheOrder/">订单信息列表</a></li>
		<li class="active"><a href="${ctx}/bishe/bisheOrder/form?id=${bisheOrder.id}">订单信息<shiro:hasPermission name="bishe:bisheOrder:edit">${not empty bisheOrder.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="bishe:bisheOrder:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="bisheOrder" action="${ctx}/bishe/bisheOrder/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">客户：</label>
			<div class="controls">
				<input  class="input-xlarge required" type="text" readonly value="${bisheOrder.client.name}" maxlength="50">
				<input name="client.id" type="hidden" value="${bisheOrder.client.id}">
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">订单内容：</label>
			<div class="controls" >
				<button onclick="tianchu()">点击添加</button>
				<table id="table">
				</table>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">订单类型：</label>
			<div class="controls">
				<form:select path="orderType" class="input-xlarge required">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('order_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">合同起租时间：</label>
			<div class="controls">
				<input name="rentStartDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					   value="<fmt:formatDate value="${bishePack.rentStartDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					   onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">合同到租时间：</label>
			<div class="controls">
				<input name="rentEndDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					   value="<fmt:formatDate value="${bishePack.rentEndDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					   onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">备注信息：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="bishe:bisheOrder:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>